Skip to content

Release GIL when calling potentially-blocking functions#22

Merged
buresu merged 1 commit into
buresu:masterfrom
minoki:release-gil
May 15, 2026
Merged

Release GIL when calling potentially-blocking functions#22
buresu merged 1 commit into
buresu:masterfrom
minoki:release-gil

Conversation

@minoki
Copy link
Copy Markdown
Contributor

@minoki minoki commented Dec 14, 2022

Thank you for this useful library!

I think the library can release the GIL when the operation blocks.
So I propose to add py::gil_scoped_release to functions with timeout parameter.

@JC3
Copy link
Copy Markdown

JC3 commented Sep 28, 2024

This is a pretty critical improvement and really ought to be merged and released.

@bmather9
Copy link
Copy Markdown
Contributor

I haven't tested this, but have struggled with some issue that I believe are related to this. Would be great to get this merged.

@buresu
Copy link
Copy Markdown
Owner

buresu commented May 15, 2026

Thank you for your PR! Sorry for the very long wait.
This is a great improvement for multi-threading. Releasing the GIL in blocking functions allows other python threads to run while waiting, which is exactly the right behavior for multi-threaded use cases.

@buresu buresu merged commit 8f5cac6 into buresu:master May 15, 2026
@buresu buresu mentioned this pull request May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants